package com.choudou5.solr.util.emoji;

import com.choudou5.solr.util.StrUtil;
import com.choudou5.solr.util.emoji.standard.EmojiParser;
import org.apache.commons.lang3.StringEscapeUtils;

import java.util.regex.Pattern;

/**
 * @name Emoji工具类
 * @author xuhaowen
 * @date 2018-08-31
 */
public class EmojiUtil extends EmojiParser {


    private static Pattern SIMPLE_PATTERN = Pattern.compile("\\[([^\\[\\]]+)\\]");

    /**
     * 移除 中文Emoji  例如： [:呆]
     * @param text
     * @return
     */
    public static String removeTextEmoji(String text) {
        if(StrUtil.isBlank(text))
            return null;
        return SIMPLE_PATTERN.matcher(text).replaceAll("");
    }

    public static void main(String[] args) {
        System.out.println(StringEscapeUtils.unescapeJava("☺"));
        System.out.println(EmojiParser.removeAllEmojis("你好☺都是"));
        System.out.println(removeTextEmoji("你好[:呆]好酷"));
    }
}
